import {Component, OnInit, ViewEncapsulation} from '@angular/core';
import {StudentTestLastScoreVO} from "@interface/index";
import {ParentService} from "@train/parent/parent.service";
import {ActivatedRoute, Params} from "@angular/router";


@Component({
  selector: 'seed-ability-grow-record',
  templateUrl: './ability-grow-record.component.html',
  styleUrls: ['./ability-grow-record.component.scss'],
  encapsulation: ViewEncapsulation.None
})
export class AbilityGrowRecordComponent implements OnInit {
  public studentId: number;
  public abilityRecordList: Array<StudentTestLastScoreVO> = [];
  public showDes: boolean = false;
  public desIndex: number;

  constructor(
    private parentService: ParentService,
    private activatedRoute: ActivatedRoute,
  ) {
    this.activatedRoute.params.subscribe((params: Params) => {
      this.studentId = params['studentId'];
      this.getStudentAbilityRecord(this.studentId);
    })
  }

  /**
   * @author guoqs1331
   * @time 2018/4/15
   * @description 能力成长记录
   */
  getStudentAbilityRecord(studentId: number) {
    this.parentService.getStudentAbilityRecord(studentId).subscribe(res => {
      console.log(res);
      this.abilityRecordList = res.data;
    })
  }

  /**
   * @author guoqs1331
   * @time 2018/4/20
   * @description
   */
  showNameDes(index) {
    if(this.desIndex!==index){
      this.showDes = true;
    }else {
      this.showDes = !this.showDes;
    }
    this.desIndex = index;
  }

  ngOnInit() {
  }

}
